package adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.itboye.hutoubenjg.R;

import base.MyApplcation;
import bean.messge_bean.MesgeBeans;
import util.utls.TimeFormat;

/**
 *消息
 */
public class MessageAdapter extends BaseAdapter {
    Context context;
    MesgeBeans been;

    public  MessageAdapter(Context context,MesgeBeans been){
        this.context=context;
        this.been=been;
    }
    @Override
    public int getCount() {
        return been.getInfo().size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHoudr houdr;
        if(convertView==null){
            houdr=new ViewHoudr();
            convertView= LayoutInflater.from(MyApplcation.ctx).inflate(R.layout.item_weixiu_messge,null);
            houdr.MessgeName= (TextView) convertView.findViewById(R.id.tvMessgeName);
            houdr.MessgeTitle= (TextView) convertView.findViewById(R.id.tvMessgeTitle);
            houdr.tvMessgeTime= (TextView) convertView.findViewById(R.id.tvMessgeTime);
            convertView.setTag(houdr);
        }else{
            houdr= (ViewHoudr) convertView.getTag();
        }
        houdr.MessgeName.setText(been.getInfo().get(position).getContent());
        houdr.MessgeTitle.setText(been.getInfo().get(position).getSummary());
        houdr.tvMessgeTime.setText(TimeFormat.DateFormat(been.getInfo().get(position).getCreate_time()));

        return convertView;
    }
    private class ViewHoudr{
        private TextView MessgeTitle;
        private TextView MessgeName;
        private TextView tvMessgeTime;
    }
}
